<template>
    <div class="body login">
        <div class="backbox"></div>
        <div class="lo_title">注册</div>
        <div class="form_li" style="margin-top: 0.8rem;">
            <span class="icon_phone"></span>
            <input type="text" placeholder="请输入手机号码" v-model="username">
        </div>
        <div class="form_li">
            <span class="icon_password"></span>
            <input type="password" placeholder="请输入密码" v-model="password">
        </div>
        <div class="lo_btn" @click="denglu">登录</div>
    </div>
</template>

<script>
    import { Toast } from 'mint-ui';
    export default {
        name: "login",
        data(){
            return {
                username:"",
                password:"",
                userid:""
            }
        },
        beforeCreate(){
            this.$store.state.navTabstatu = 1
        },
        mounted(){
            console.log(this.common.baseURL);
        },
        methods:{
            denglu(){
                if(this.username==""||this.password==""){
                    return Toast({
                        message: "请填写登录信息",
                        position: 'center',
                        duration: 2000
                    });
                }
                // if(this.username=="wjx"&&this.password=="123456"){
                //     this.$router.push({path: '/productList', query: {selected: "2"}})
                // }else{
                //     return Toast({
                //         message: "用户名密码错误",
                //         position: 'center',
                //         duration: 2000
                //     });
                // }

                this.axios({
                    method: 'post',
                    url: this.common.baseURL + '/login?password='+this.password+'&username='+this.username,
                    // url: '/login',
                    // url:'http://localhost:8001/apis/login',
                    data:this.qs.stringify({
                        username: this.username,
                        password: this.password
                    }),
                    withCredentials: true,
                }).then((response) => {
                    if(response.data.code==0){
                        localStorage.hhrdata = JSON.stringify(response.data.data)
                        this.$router.push({path: '/productList', query: {selected: "2"}})
                    }else{
                        Toast({
                            message: response.data.message,
                            position: 'center',
                            duration: 2000
                        });
                    }
                }).catch((error) => {
                    console.log(error);
                });
                //this.$router.push({path: '/productList', query: {navStatus: "2"}})
            }
        }
    }
</script>

<style scoped lang="less">
    .login {
        .backbox{
            height: 5.72rem;
            background: url("../img/login_back.png") center center no-repeat;
            background-size: 100% auto;
        }
        .lo_title{
            font-size:0.48rem;
            font-weight:500;
            color:rgba(38,119,249,1);
            text-align: center;
            margin:  0.46rem auto;
            letter-spacing: 0.1rem;
        }
        .form_li{
            height: 0.9rem;
            overflow: hidden;
            line-height: 0.9rem;
            margin: 0 0.75rem;
            .icon_phone{
                background: url("../img/login_icon.png") center center no-repeat;
                background-size: 100%;
            }
            .icon_password{
                background: url("../img/login_icon1.png") center center no-repeat;
                background-size: 100%;
            }
            span{
                float: left;
                width: 0.42rem;
                height: 0.42rem;
                margin: 0.24rem 0.6rem 0 0;
            }
            input{
                float: left;
                width: 4.7rem;
                height: 0.6rem;
                margin: 0.15rem 0;
                line-height: 0.5rem;
                padding: 0 0.1rem;
                font-size: 0.32rem;
                border: 0;
            }
        }
        .lo_btn{
            width:6rem;
            height:0.88rem;
            background:rgba(38,119,249,1);
            border-radius:0.44rem;
            font-weight:500;
            color:rgba(255,255,255,1);
            line-height: 0.88rem;
            text-align: center;
            cursor: pointer;
            margin:  0.9rem auto;
        }
    }
</style>
